<template>
  <view class="container">
    <view class="page-title">意见反馈</view>
    
    <view class="feedback-container">
      <view class="feedback-type">
        <text class="type-label">反馈类型</text>
        <view class="type-options">
          <view class="type-option" 
                :class="selectedType === type.value ? 'selected' : ''"
                @click="selectedType = type.value"
                v-for="type in feedbackTypes" :key="type.value">
            {{ type.label }}
          </view>
        </view>
      </view>
      
      <view class="feedback-content">
        <text class="content-label">反馈内容</text>
        <textarea v-model="feedbackContent" placeholder="请输入您的反馈内容..." class="content-input"></textarea>
        <text class="content-count">{{ feedbackContent.length }}/500</text>
      </view>
      
      <button class="submit-btn" @click="submitFeedback">提交反馈</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      feedbackTypes: [
        { label: '功能问题', value: 'function' },
        { label: '界面建议', value: 'ui' },
        { label: '性能问题', value: 'performance' },
        { label: '其他问题', value: 'other' }
      ],
      selectedType: 'function',
      feedbackContent: ''
    }
  },
  methods: {
    submitFeedback() {
      if (!this.feedbackContent.trim()) {
        return uni.showToast({ title: '请输入反馈内容', icon: 'none' })
      }
      
      if (this.feedbackContent.length > 500) {
        return uni.showToast({ title: '反馈内容不能超过500字', icon: 'none' })
      }
      
      // 模拟提交
      uni.showLoading({ title: '提交中...' })
      setTimeout(() => {
        uni.hideLoading()
        uni.showToast({ title: '反馈提交成功，感谢您的建议！' })
        // 清空表单
        this.feedbackContent = ''
        // 返回上一页
        setTimeout(() => {
          uni.navigateBack()
        }, 1500)
      }, 1000)
    }
  }
}
</script>

<style scoped>
.container {
  background-color: #f5f5f5;
  min-height: 100vh;
}

.page-title {
  font-size: 36rpx;
  font-weight: bold;
  text-align: center;
  padding: 30rpx 0;
  background-color: #fff;
  border-bottom: 1px solid #eee;
}

.feedback-container {
  margin-top: 20rpx;
  background-color: #fff;
  padding: 30rpx;
}

.feedback-type {
  margin-bottom: 30rpx;
}

.type-label, .content-label {
  font-size: 30rpx;
  color: #333;
  display: block;
  margin-bottom: 15rpx;
}

.type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 20rpx;
}

.type-option {
  padding: 15rpx 30rpx;
  border: 1px solid #ddd;
  border-radius: 30rpx;
  font-size: 26rpx;
  color: #666;
}

.type-option.selected {
  border-color: #ff5722;
  background-color: rgba(255, 87, 34, 0.1);
  color: #ff5722;
}

.feedback-content {
  margin-bottom: 40rpx;
}

.content-input {
  width: 100%;
  min-height: 200rpx;
  border: 1px solid #eee;
  border-radius: 8rpx;
  padding: 20rpx;
  font-size: 28rpx;
  line-height: 1.6;
}

.content-count {
  display: block;
  text-align: right;
  font-size: 24rpx;
  color: #999;
  margin-top: 10rpx;
}

.submit-btn {
  width: 100%;
  background-color: #ff5722;
  color: #fff;
  font-size: 32rpx;
  padding: 25rpx 0;
  border-radius: 8rpx;
}
</style>